/*
 * @Date: 2021-09-05 20:28:39
 * @Author: Acckno1
 * @LastEditTime: 2021-09-07 20:33:14
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}


const int N = 1010;

int n;
int nums[N];
int l[N], r[N];


PII BFS(int u) {
    int f = 0, s = 0;
    queue<int> q;
    q.push(u);
    while (q.size()) {
        int n = q.size();
        f = s, s = n;
        for (int i = 0; i < n; i ++ ) {
            int head = q.front(); q.pop();
            if (l[head] != -1) q.push(l[head]);
            if (r[head] != -1) q.push(r[head]);
        }
    }
    return mk(f, s);
}

// 需要先构建图 但是构图的时候不能用初始值构图 需要离散化数据构图
inline void solution() {
    mm(l, -1);
    mm(r, -1);
    cin >> n;
    int root, idx = 0;
    unordered_map<int, int> hash;
    for (int i = 0; i < n; i ++ ) {
        int v;
        cin >> v;
        hash[i] = v;
        int p = 0;
        while (i) {
            if (hash[i] > hash[p]) {
                if (r[p] != -1) {
                    p = r[p];
                    continue;
                } else {
                    r[p] = i;
                    break;
                }
            } else {
                if (l[p] != -1) {
                    p = l[p];
                    continue;
                } else {
                    l[p] = i;
                    break;
                }
            }
        }
    }
    auto res = BFS(0);
    cout << res.second << " + " << res.first << " = " << res.second + res.first << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}